public BarcodeData(BarcodeSymbology symbology,byte[] data)
Public Function New( _ByVal symbology As BarcodeSymbology, _ByVal data() As Byte _)
public:BarcodeData(BarcodeSymbology symbology,array<byte>^ data)
symbology
Barcode symbology to use.
data
An array of Byte that specifies the data to use. This value can be null (Nothing in VB).
This constructor initializes the BarcodeData member as follows:
| Member | Value |
|---|---|
| Symbology | symbology |
| Bounds | LeadRect.Empty |
| RotationAngle | 0 |
| BarWidthReduction | 0 |
| Byte array inside GetData | data (same reference, the data is not copied) |
| Value | ASCII text string representation of data, if this parameter is null, then Value is null too. |
| Tag | null (Nothing in Visual Basic) |
To quickly construct a new BarcodeData object with a specific symbology and data as a string value, use BarcodeData(BarcodeSymbology symbology, string value) to construct a default BarcodeData, use BarcodeData().
To create an instance of BarcodeData suitable for writing for a specified symbology, use CreateDefaultBarcodeData.
This example creates a BarcodeData using specified symbology and raw data. Then it writes it to an image.
using Leadtools;using Leadtools.Codecs;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeData_FromByteArrayExample(){string outFileName = Path.Combine(LEAD_VARS.ImagesDir, @"MyBarcode.tif");// This is UPC data to save a a stringstring originalString = "01234567890";// We will get it as a byte array to use in the rest of this examplebyte[] bytes = Encoding.ASCII.GetBytes(originalString);// Create a BarcodeData object from this dataBarcodeData data = new BarcodeData(BarcodeSymbology.UPCA, bytes);data.Bounds = new LeadRect(0, 0, 400, 200);// Make sure it is the sameDebug.Assert(data.Value == originalString);// Write it to an imageBarcodeEngine engine = new BarcodeEngine();using (RasterCodecs codecs = new RasterCodecs()){int resolution = 300;LeadRect pixels = data.Bounds;using (RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))){engine.Writer.WriteBarcode(image, data, null);codecs.Save(image, outFileName, RasterImageFormat.Tif, 1);}}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeData_FromByteArrayExample()Dim outFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcode.tif")' This is UPC data to save a a stringDim originalString As String = "01234567890"' We will get it as a byte array to use in the rest of this exampleDim bytes() As Byte = Encoding.ASCII.GetBytes(originalString)' Create a BarcodeData object from this dataDim data As New BarcodeData(BarcodeSymbology.UPCA, bytes)data.Bounds = New LeadRect(0, 0, 400, 200)' Make sure it is the sameDebug.Assert(data.Value = originalString)' Write it to an imageDim engine As New BarcodeEngine()Using codecs As New RasterCodecs()Dim resolution As Integer = 300Dim pixels As LeadRect = data.BoundsUsing image As RasterImage = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))engine.Writer.WriteBarcode(image, data, Nothing)codecs.Save(image, outFileName, RasterImageFormat.Tif, 1)End UsingEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
